<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>数组查找元素位置</title>
	</head>

	<body>
		<h4>题目描述</h4>
		<p>在数组 arr 中，查找值与 item 相等的元素出现的所有位置</p>
		<span>findAllOccurrences('abcdefabc'.split(''), 'a').sort()</span>
		<script>
			function findAllOccurrences (a,s) {
				var arr = a;
				var indexs = [];
				arr.forEach( (i,index) => {
					if(i === s) {
						indexs.push(index);
					}
				} );

				return indexs;
			}

			console.log(findAllOccurrences('abcdefabc'.split(''), 'a'));
		</script>
	</body>
	 
	 		

</html>